import {
    defineConfig,
    presetAttributify,
    presetIcons,
    presetTypography,
    presetWind,
    // presetUno,
    // presetWebFonts,
    transformerDirectives,
    transformerVariantGroup,
} from 'unocss'

// import epIcons from '@iconify-json/ep'

const iconPrefix = 'i-'

export default defineConfig({
    shortcuts: [

    ],
    variants: [
        {
            match: (s) => {
                if (s.startsWith(iconPrefix)) {
                    return {
                        matcher: s,
                        selector: (s) => {
                            return s.startsWith('.') ? `${s.slice(1)},${s}` : s
                        },
                    }
                }
            },
        },
    ],
    presets: [
        presetAttributify(),
        presetIcons({
            scale: 1.2,
            warn: true,
            prefix: iconPrefix,
        }),
        presetTypography(),
        presetWind(), // 完全模拟 Tailwind CSS 的预设
        // presetUno(), // UnoCSS默认预设（preset）
        // TODO 自动从 Google Fonts 加载这些字体(国内不建议使用，太慢了)
        // presetWebFonts({
        //     fonts: {
        //         sans: 'DM Sans',
        //         serif: 'DM Serif Display',
        //         mono: 'DM Mono',
        //     },
        // }),
    ],
    transformers: [
        transformerDirectives(),
        transformerVariantGroup(),
    ],
    safelist: [
        ...'prose prose-sm m-auto text-left'.split(' '),
        // ...Object.keys(epIcons.icons.icons).map(name => `${iconPrefix}${epIcons.icons.prefix}-${name}`),
    ],
    theme: {
        colors: {
            primary: 'var(--el-color-primary)',
        },
    },
})
